// => numeric

// Includes

#include <stdlib.h>

// Types

typedef struct UnaryFunc {
  double (*f)(double);
} UnaryFunc;

// Functions

UnaryFunc *InitUnaryFunc(double (*f)(double)) {
  UnaryFunc *uf = calloc(1, sizeof(UnaryFunc));
  uf->f = f;
  return uf;
}

double diff(UnaryFunc *f, double x) {
  double dx = 1e-5;
  return (f->f(x + dx) - f->f(x)) / dx;
}